import { createRouter, createWebHistory } from "vue-router";
import {
  EmitsDemo,
  PropsDemo,
  EmitterDemo,
  AttrsDemo,
  InjectDemo,
  ScopedSlotDemo,
} from "../views";

export const routes = [
  {
    name: "propsDemo",
    path: "/props-demo",
    component: PropsDemo,
    meta: {
      title: "Props 传值",
    },
  },
  {
    name: "emitsDemo",
    path: "/emits-demo",
    component: EmitsDemo,
    meta: {
      title: "Emits 传值",
    },
  },
  {
    name: "emitterDemo",
    path: "/emitter-demo",
    component: EmitterDemo,
    meta: {
      title: "mitt 传值",
    },
  },
  {
    name: "attrsDemo",
    path: "/attrs-demo",
    component: AttrsDemo,
    meta: {
      title: "$attrs 传值",
    },
  },
  {
    name: "injectDemo",
    path: "/inject-demo",
    component: InjectDemo,
    meta: {
      title: "inject 传值",
    },
  },
  {
    name: "scopedSlotDemo",
    path: "/scoped-slot-demo",
    component: ScopedSlotDemo,
    meta: {
      title: "作用域插槽",
    },
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes: [
    ...routes,
    {
      path: "/",
      redirect: "/props-demo",
    },
  ],
});

export default router;
